package com.jt.common.vo;

import java.io.Serializable;
import java.util.List;

public class PageObject<T> implements Serializable {

	private static final long serialVersionUID = -2226460946853591115L;
	// 当前页的页码值
	private Integer pageCurrent = 1;
	// 页面大小
	private Integer pageSize = 3;
	// 总行数
	private Integer rowCount = 0;
	// 总页数
	private Integer pageCount = 0;
	// 当前页记录
	private List<T> records;

	public Integer getPageCurrent() {
		return pageCurrent;
	}

	public void setPageCurrent(Integer pageCurrent) {
		this.pageCurrent = pageCurrent;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getRowCount() {
		return rowCount;
	}

	public void setRowCount(Integer rowCount) {
		this.rowCount = rowCount;
	}

	/**
	 * 计算总页数，当控制层对象将此对象转换为json串时，底层会调用对象的get方法，所以 我们可以将总页数的计算放在此方法中
	 * 
	 * @return
	 */
	public Integer getPageCount() {
		pageCount = rowCount / pageSize;
		if (rowCount % pageSize != 0) {
			pageCount++;
		}
		return pageCount;
	}

	public void setPageCount(Integer pageCount) {
		this.pageCount = pageCount;
	}

	public List<T> getRecords() {
		return records;
	}

	public void setRecords(List<T> records) {
		this.records = records;
	}

	@Override
	public String toString() {
		return "PageObject [pageCurrent=" + pageCurrent + ", pageSize=" + pageSize + ", rowCount=" + rowCount
				+ ", pageCount=" + pageCount + ", records=" + records + "]";
	}

}
